package com.mzy.linear_struct.hot100.二叉树;

/**
 * @Author: mizy3
 * @Date: 2024/08/10/下午6:41
 * @Description:
 */
public class Pro101对称二叉树 {
    public boolean isSymmetric(TreeNode root) {
        return isMirror(root, root);
    }

    private boolean isMirror(TreeNode left, TreeNode right) {
        if (left == null && right == null) {
            return true;
        }
        if (left == null || right == null) {
            return false;
        }
        return isMirror(left.left, right.right) && isMirror(left.right, right.left) && left.val == right.val;
    }
















    /*public boolean isSymmetric(TreeNode root) {
        return isMirror(root, root);
    }

    private boolean isMirror(TreeNode left, TreeNode right) {
        if (left == null && right == null) return true;
        if (left == null || right == null) {
            return false;
        }

        return left.val == right.val && isMirror(left.left, right.right) && isMirror(left.right, right.left);
    }*/


}

